if ((winprofile.Right(1)!="/") && (winprofile.Right(1)!="\\"))
winprofile+="\\";
winprofile+="hts-cache\\";
{
char tempo[HTS_URLMAXSIZE*2];
int i;
strcpy(tempo,winprofile);
for(i=0;i<(int)strlen(tempo);i++)
if (tempo[i]=='\\')
tempo[i]='/';
structcheck(tempo);
}
winprofile+="winprofile.ini";
Write_profile(winprofile,0);
// marquer document comme "sauvΘ"
if (this_CSplitterFrame)
this_CSplitterFrame->SetSaved();
return IDYES;
}
// reprise possible?
int check_continue(char* pathlog) {
char path_log[256];
strcpy(path_log,pathlog);
if (strlen(path_log)>0)
if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\'))
strcat(path_log,"/");
if ((fexist(fconcat(path_log,"hts-cache/new.dat"))) && (fexist(fconcat(path_log,"hts-cache/new.ndx")))) { // il existe dΘja un cache prΘcΘdent.. renommer
//if (fexist(fconcat(path_log,"hts-cache/doit.log"))) { // un cache est prΘsent
return 1;
//}
}
if ((fexist(fconcat(path_log,"hts-cache/old.dat"))) && (fexist(fconcat(path_log,"hts-cache/old.ndx")))) { // il existe dΘja un ancien cache prΘcΘdent.. renommer
return 1;
}
AfxMessageBox(LANG(LANG_F2 /*"There is no cache in the directory indicated\nWinHTTrack can not find any interrupted mirror!"*/),MB_OK+MB_ICONSTOP);
return 0;
}
void CShellApp::OptPannel() {
Write_profile("<mem>",0); // enregistrer profile dans buffer local
int __cdecl httrackengine_check(char* adr,char* fil,int status) { // appelΘ par le wizard
return -1;
}
void __cdecl httrackengine_init() { // appelΘ lors de l'init de HTTRACK, avant le dΘbut d'un miroir
#if USE_RAS
has_started=0;
#endif
httrackengine_loop(NULL,0,0,0,0,NULL,0); // init
//printf("DEMARRAGE DU MIROIR DETECTE\n");
}
void __cdecl httrackengine_uninit() { // appelΘ en fin de miroir (peut Ωtre utile!!!)
#if USE_RAS
if (LibRasUse) { /* librairie RAS chargΘe */
if (disconnect) { /* on doit dΘconnecter */
if (connected) { /* on a initiΘ une connexion */
if (conn)
LibRas->RasHangUp(conn);
} else { /* tout dΘconnecter */
// On coupe tout (non, pas bourrin)
DWORD size;
RASCONN* adr;
int count=256;
size = sizeof(RASCONN)*(count+2);
adr = (RASCONN*) (char*) calloc(size,1);
if (adr) {
DWORD ent;
int i;
for(i=0;i<count;i++) {
adr[i].dwSize=sizeof(RASCONN);
strcpy(adr[i].szEntryName,"");
}
if (LibRas->RasEnumConnections((RASCONN*) adr,&size,&ent) == 0) {
for(i=0;i<(int)ent;i++) {
LibRas->RasHangUp(adr[i].hrasconn);
}
}
free(adr);
}
}
}
}
#endif
}
int __cdecl httrackengine_start(void* dummy) { // appelΘ lors du dΘmarrage du miroir (premiΦres requΦtes)
#if USE_RAS
// connexion RAS
has_started=1; // dΘmarrage
connected=0;
conn = NULL;
memset(&SInfo, 0, sizeof(SInfo));
if (LibRasUse) {
if (strlen(OPTION_RasString)>0) { // sΘlection provider
if (!LibRas->RasDial(NULL,NULL,&OPTION_dial,NULL,NULL,&conn)) {
RASCONNSTATUS status;
do {
status.dwSize = sizeof(status);
LibRas->RasGetConnectStatus(conn,&status);
switch(status.rasconnstate) {
case RASCS_Connected :
connected=1;
break;
case RASCS_Disconnected :
strcpy(connected_err,LANG(LANG_F3 /*"Could not connect to provider"*/));
connected=-1;
break;
}
} while(connected==0);
} else {
strcpy(connected_err,LANG(LANG_F3 /*"Could not connect to provider","Impossible d'Θtablir la connexion"*/));
connected=-1;
//termine=1;
}
}
//
if (connected != -1) // si pas d'erreur RAS
return 1;
else
return 0;
} else
return 1;
#else
return 1;
#endif
}
int httrackengine_end() { // appelΘ lors de la fin du miroir (plus de liens α charger)
WHTT_LOCK();
termine=1;
if (_Cinprogress_inst) {
_Cinprogress_inst->EndDialog(IDOK);
_Cinprogress_inst=NULL;
}
WHTT_UNLOCK();
return 1;
}
int __cdecl httrackengine_htmlcheck(char* html,int len,char* url_adresse,char* url_fichier) { // appelΘ α chaque fois qu'un html doit Ωtre scannΘ (utile pour la prospection mais inutile ici)
return 1;
}
int __cdecl httrackengine_chopt(void* opt) {
return 1;
}
// Le routine la plus utile sans doute: elle refresh les tableaux
// C'est la 2e routine en thread qui assure le refresh graphique
// (plus efficace)
// -->C'est elle qui dΘcide de tout arrΩter si elle dΘtecte in termine_request<--
int __cdecl httrackengine_loop(
void* _back,int back_max,int back_index,
int lien_n,int lien_tot,
int stat_time,
hts_stat_struct* stats) { // appelΘ α chaque boucle de HTTrack
static char s[HTS_URLMAXSIZE*2]=""; // utilisΘ plus loin
int stat_written=-1;
int stat_updated=-1;
int stat_errors=-1;
int stat_warnings=-1;
int stat_infos=-1;
int nbk=-1;
LLint nb=-1;
int stat_nsocket=-1;
LLint stat_bytes=-1;
LLint stat_bytes_recv=-1;
int irate=-1;
WHTT_LOCK();
if (stats) {
stat_written=stats->stat_files;
stat_updated=stats->stat_updated_files;
stat_errors=stats->stat_errors;
stat_warnings=stats->stat_warnings;
stat_infos=stats->stat_infos;
nbk=stats->nbk;
stat_nsocket=stats->stat_nsocket;
irate=(int)stats->rate;
nb=stats->nb;
stat_bytes=stats->nb;
stat_bytes_recv=stats->HTS_TOTAL_RECV;
}
#if !SHELL_MULTITHREAD
static TStamp last_time;
#endif
int rate;
// casts
lien_back* back=(lien_back*) _back;
// static int ft=-1;
if (back_max == 0) {
#if !SHELL_MULTITHREAD
last_time=0;
#endif
// en cas de manque de time
SInfo.stat_timestart=time_local();
WHTT_UNLOCK();
return 1;
}
if ((termine) || (termine_requested)) {
SInfo.refresh=0; // pas de refresh
SInfo.refresh=0; // pas de refresh
termine_requested=1;
WHTT_UNLOCK();
return 0;
}
if (stat_written>=0) SInfo.stat_written=stat_written;
if (stat_updated>=0) SInfo.stat_updated=stat_updated;
if (stat_errors>=0) SInfo.stat_errors=stat_errors;
if (stat_warnings>=0) SInfo.stat_warnings=stat_warnings;
if (stat_infos>=0) SInfo.stat_infos=stat_infos;
#if SHELL_MULTITHREAD
//if (((tl-last_time)>=100) || ((tl-last_time)<0)) { // chaque 100 ms
if (SInfo.ask_refresh) {
#else
TStamp tl=0;
{
time_t tt;
struct tm* A;
tt=time(NULL);
A=localtime(&tt);
tl+=A->tm_sec;
tl+=A->tm_min*60;
tl+=A->tm_hour*60*60;
//tl+=A->tm_yday*60*60*24;
//tl+=A->tm_year*60*60*24*365;
tl*=1000; // en ms
struct _timeb timebuffer;
char *timeline;
_ftime( &timebuffer );
timeline = ctime( & ( timebuffer.time ) );
tl+=timebuffer.millitm; // + ms
}
if (((tl-last_time)>=HTS_SLEEP_WIN) || ((tl-last_time)<0)) { // chaque 250 ms
if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\'))
strcat(path_log,"/");
// on efface le doit.log, pour annuler les parametres anciens et en redΘfinir de nouveaux
// c'est ici une logique qui diffΦre de la version en ligne de commande
//if ((fexist(fconcat(path_log,"hts-cache/new.dat"))) && (fexist(fconcat(path_log,"hts-cache/new.ndx")))) { // il existe dΘja un cache prΘcΘdent.. renommer
if (fexist(fconcat(path_log,"hts-cache/new.ndx"))) { // un cache est prΘsent
if (fexist(fconcat(path_log,"hts-cache/doit.log")))
strcat(end_mirror_msg,LANG(LANG_F21 /*"\nSee the log file if necessary.\n\nClick OK to quit WinHTTrack.\n\nThanks for using WinHTTrack!","\nVoir le fichier log au besoin\n\nCliquez sur OK pour quitter WinHTTrack\n\nMerci d'utiliser WinHTTrack."*/));
//AfxMessageBox(s,MB_OK+MB_ICONINFORMATION);
} else {
strcpy(end_mirror_msg,LANG(LANG_F22 /*"The mirror is finished.\nClick OK to quit WinHTTrack.\nSee log file(s) if necessary to ensure that everything is OK.\n\nThanks for using WinHTTrack!","Le miroir est terminΘ\nCliquez sur OK pour quitter WinHTTrack\nVoir au besoin les fichiers d'audit pour vΘrifier que tout s'est bien passΘ\n\nMerci d'utiliser WinHTTrack!"*/));
//AfxMessageBox("The mirror is finished.\nClic OK to quit WinHTTrack.\nSee log file(s) if necessary to ensure that everything is OK.\n\nThanks for using WinHTTrack!",MB_OK+MB_ICONINFORMATION);
// ShellExecute(0,"open",,"","",);
}
#if USE_RAS
// erreur ras
if (connected == -1)
if ((int) strlen(connected_err) > 0)
strcpy(end_mirror_msg,connected_err);
#endif
{
char pathlog[HTS_URLMAXSIZE*2];
strcpy(pathlog,dialog0->GetPath());
Ciplog form;
if (strlen(pathlog)>0)
if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
strcat(pathlog,"/");
// fichier log existe ou on est tΘlΘcommandΘ par un !
if ( (fsize(fconcat(pathlog,"hts-err.txt")))>0) {
strcat(end_mirror_msg,LANG(LANG_F23 /*"\n\nTip: Click [View log file] to see warning or error messages","\n\nConseil: [Voir fichiers log] pour voir les erreurs et messages"*/));
}
}
//this_Cinfoend->m_infoend = msg;
inprogress->SendMessage(WM_USER + 4); // avertir
if (fp_debug) {
fprintf(fp_debug,"DoModal end dialog, waiting\r\n");
fflush(fp_debug);
}
/*
if (info.DoModal() == IDC_NewProject) { // relancer programme!
// copie de onnewproject() de wid1::
CWinApp* pApp = AfxGetApp();
CString name = pApp->m_pszHelpFilePath;
name=name.Left(name.GetLength()-4);
name += ".EXE";
ShellExecute(NULL,"open",name,"","",SW_RESTORE);
}
*/
if (fp_debug) {
fprintf(fp_debug,"Final info OK, leaving..\r\n");
fflush(fp_debug);
}
}
else {
}
}
// int LANG_T(int);
// char* LANG(char* english,char* francais);
/* interface lang - lang_string="stringlang0\nstringlang1\n..laststring" */